// pages/first/first.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    images:["https://gitee.com/ToBugCoding/my-photo-bed/raw/master/imgurl/%E5%85%AC%E5%8F%B8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%86%99/ze-arrow-left%20lmgi6zF@3x.png","https://gitee.com/ToBugCoding/my-photo-bed/raw/master/imgurl/%E5%85%AC%E5%8F%B8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%86%99/firstbg.png","https://gitee.com/ToBugCoding/my-photo-bed/raw/master/imgurl/%E5%85%AC%E5%8F%B8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%86%99/%E6%94%BE%E5%A4%A7%E9%95%9C.png"],
    loadedImages:0,
    ifready:true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  takePhoto(){	
    app.globalData.photoType="",
    wx.requestSubscribeMessage({
      tmplIds: ["-WTRz9G1fH_LYOC4L90i41H6DXhQ-YfsE4YNCuWe50Q"],
      success:function(res){
        console.log(res)
      },
      fail:function(res){
        console.log(res)
      },
    })
    wx.navigateTo({
      url: '/pages/shot1/shot1',	//跳转到自定义的一个拍照页面
    })
  },
  takeAllPhoto(){
    wx.navigateTo({
      url: '/pages/tooth/tooth',
    })
  },
  back:function(){
    wx.switchTab({
      url: '/pages/head/head',
    })
  },
  onLoad(options) {
    var that=this
    console.log("页面传参测试："+options.userid)
    if(that.data.ifready!='none'){
      let images = this.data.images;
      images.forEach((imgSrc, index) => {
        wx.getImageInfo({
          src: imgSrc,
          success: () => {
            // 图片加载成功
            this.setData({
              loadedImages: this.data.loadedImages + 1
            });
            if (this.data.loadedImages === images.length) {
              if(this.data.ifready==true)
              {
                setTimeout(() => {
                  that.setData({
                    ifready:'none'
                  })
                }, 500);
              }
            }
          },
          fail: () => {
            // 图片加载失败
            console.log(`图片${index + 1}加载失败`);
          }
        });
      });
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})